package com.distributer.gateway.hander;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * 业务线程工厂
 * @author xiaolin
 *
 */
public class BusinessThreadFactory implements ThreadFactory{

	private final String threadName;
	
	private static final AtomicInteger count = new AtomicInteger();
	
	public BusinessThreadFactory(String threadName) {
		this.threadName = threadName;
	}

	@Override
	public Thread newThread(Runnable runnable) {
		String name = threadName +"_"+count.incrementAndGet();
		Thread thread = new Thread(runnable, name);
		thread.setDaemon(false);
		return thread;
	}

}
